home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / due-crk.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-16  |  5.4 KB  |  153 lines

  1. //***********************************************************
  2. //*   solution for Duelist's Crackme #3 , solved by Nuno1   *
  3. //*   any comments can be sent to nuno_2@hotmail.com        *
  4. //***********************************************************
  5.  
  6. //this program will run for around 7 min and will return a binary like number
  7. //that 0 mean OFF and 1 mean ON .
  8.  
  9. //when finished , the last number will be the answer ,
  10. //the number will be 01100110110010010. and it is the right key
  11. //for the crackme.
  12. //
  13. //you are welcome to run it yourself and wait till it reach the end ;).
  14. //
  15. //before trying to understand the code here,read the tutorial for the crackme.
  16. //Have a good time ;)
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20.  
  21. #define RESULT_NUMBER 0xf35466 //this is the result number we need to reach.
  22. #define NUMBER_OF_CHECKBOXS 18 //as the name said .. number of checkboxs.
  23.  
  24. #define TRUE  1     //some defines that will help us make the code look good.
  25. #define FALSE 0
  26.  
  27.     //this table is the check box table .
  28.     //each checkbox doesn't represent the "REAL" checkbox number.
  29.     //for example the first checkbox on the crackme is really 17 . (11h)
  30.     //so this is a transalation table for the checkbox.
  31.     int CheckBoxTable[18]={17,2 ,3 ,1 ,8 ,
  32.                            6 ,7 ,10,11,4 ,
  33.                            12,13,14,15,16,
  34.                            18,5 ,9};
  35.  
  36.     //this is the table that the crackme multiply from
  37.     //see above for the use of it..
  38.     int MulTable[19] = {0x16,0x49,0x5e,0x15,0x27,0x26,
  39.                         0x21,0x25,0x1d,0x59,0x53,0x37,
  40.                         0x31,0x48,0x5d,0x0c,0x61,0x52,
  41.                         0x4d};
  42.  
  43.     //this Table is the checkboxs that we are building.
  44.     int CheckBoxs[18] = {0,0,0,0,0,0,0,0,0,
  45.                          0,0,0,0,0,0,0,0,0};
  46.  
  47. //***************************************************************//
  48. //*int ChkCheckBox() - this function make the calculation of the*//
  49. //*                       crackme with the 'CheckBoxs' table and   *//
  50. //*                       return TRUE if the result is equal to    *//
  51. //*                    RESULT_NUMBER number.                    *//
  52. //***************************************************************//
  53.  
  54. int ChkCheckBox() {
  55.     long t;
  56.     unsigned long Total = 0; //total will hold the current CheckBoxs state
  57.                              //result.
  58.  
  59.     long Num1=0,Num2=0;      //some used numbers in the crackme.
  60.  
  61.     //here we start to make the calculation of the crackme as we debugged it.
  62.  
  63.     Num1 = MulTable[0]; //Num1 take the first number from the MulTable;
  64.  
  65.     //we start a loop on all the checkboxs.
  66.     for(t=0;t<18;t++) {
  67.         //checking if the checkbox is ON or OFF.
  68.         if(CheckBoxs[t]) {
  69.             //if checkbox is ON we do the above calculation.
  70.             Num2 = MulTable[t+1]; //take the next number from the MulTable
  71.             Num2 = Num2 * Num1;   //Multiply it with the old Number.
  72.             Num2 = Num2 * (t+1);  //Multiply the result with the checkbox
  73.                                   //Index.
  74.             Total= Total + Num2;  //and finally add it to the Total.
  75.         }
  76.         Num1 = MulTable[t+1]; //Num1 now gets the Next number from
  77.                               //The MulTable.
  78.  
  79.     }
  80.     //when finished the loop , we multpily it with 0x4d.
  81.     Total = Total * 0x4d;
  82.     //checking if the Total equal to the result.
  83.     if(Total == RESULT_NUMBER)
  84.         //if it is .. we found the number we return TRUE.
  85.         return TRUE;
  86.     else
  87.         //if not .. to bad .. FALSE.
  88.         return FALSE;
  89. }
  90.  
  91.  
  92. //**************************************************************************//
  93. //*void FindCombination(int Level) - This function print all Combinations  *//
  94. //*                                     Until the right one . if no one found *//
  95. //*                                     return and finished.                  *//
  96. //*                                  Level can be named CheckBox, it used  *//
  97. //*                                  when call himself to move to the next *//
  98. //*                                     CheckBox.                               *//
  99. //**************************************************************************//
  100.  
  101. void FindCombination(int Level) {
  102.     int t;
  103.     //we have to print the checkbox when we got to the last one and
  104.     //we dont want to continue so we do this statment..
  105.     if (Level != NUMBER_OF_CHECKBOXS) {
  106.         //first we put a FALSE in the checkbox.
  107.         CheckBoxs[Level] = FALSE;
  108.         //then we call to the Next Level (CheckBox).
  109.         FindCombination(Level+1);
  110.         //in second stage we put it in TRUE.
  111.         CheckBoxs[Level] = TRUE;
  112.         FindCombination(Level+1);
  113.         //as you may understand the first time we finished 18 checkboxs
  114.         //it will look like that : 000000000000000000
  115.         //second one will be     : 000000000000000001
  116.         //after                  : 000000000000000010
  117.         //and after              : 000000000000000011
  118.         //and so on and so on ;)
  119.     }
  120.     else
  121.     {
  122.         //if it got to the last level we need first to print the checkboxs.
  123.         for(t=0;t<18;t++)
  124.             //as i said before , the checkboxs are not really in the "REAL"
  125.             //places. so i use the CheckBoxTable to know witch one is the
  126.             //real one.
  127.             printf("%d",CheckBoxs[(CheckBoxTable[t]-1)]);
  128.  
  129.         //nice little line feed ;)
  130.         printf("\n");
  131.  
  132.         //is it the right combination ??
  133.         if(ChkCheckBox()) {
  134.             //yeah !! it is ! exit and the last number is the right one.
  135.             exit(1);
  136.         }
  137.     }
  138. }
  139.  
  140. //*****************************************
  141. //                Main program             //
  142. //*****************************************
  143.  
  144. void main() {
  145.     //we just call the sweet lovely FindCombination and tell him
  146.     //to start with the first checkbox (0 is the first one).
  147.     FindCombination(0);
  148.     //if it continue until here .. it means that no combination found
  149.     //for the RESULT_NUMBER .
  150.     printf("hey !! there is no combination for the number %lX.\n",RESULT_NUMBER);
  151.  
  152. }
  153. //end of the program.